<%@ page contentType = "text/html; charset=utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import="dr.member.domain.Member"%>

<html>
<head>
<title>게시판</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script language="javascript">
  function check(){
   if(document.search.keyWord.value==""){
     alert("검색어를 입력하세요");
     document.search.keyWord.focus();
     return false;
   }
   document.search.submit();
  }
</script>
</head>

<body>
<center>
<form action="list.do" name="search" method="get" onsubmit="return check()">
<table>
	<tr>
    <td align="center" valign="bottom">
      <select name="keyField">
      	<option value="subject">제목</option>  
     </select>
    </td>
    <td>
    	<input type="text" size=16 name="keyWord">
    </td>
    
    <td>
     <input type="submit" value="찾기"></td>
   </tr> 
</table>
</form>
<!-- /////////////////////////////////////////////// --> 
<form action="list.do" name="search" method="get" onsubmit="return check()">
<table>
	<tr>
    <td align="center" valign="bottom">
      <select name="keyField"> 
        <option value="id">이름</option>
     </select>
    </td>
    <td>
    	<input type="text" size=16 name="keyWord">
    </td>
    <td>
     <input type="submit" value="찾기"></td>
   </tr>
</table>
</form>
<!-- /////////////////////////////////////////////// -->
<form action="list.do" name="search" method="get" onsubmit="return check()">
<table>
	<tr>
    <td align="center" valign="bottom">
      <select name="keyField">
      	<option value="content">내용</option>
     </select>
    </td>
     <td>
    	<input type="text" size=16 name="keyWord">
    </td>
    <td>
     <input type="submit" value="찾기"></td>
   </tr>
</table>
</form>


<table width="700" cellpadding="0" cellspacing="0">
<tr>
    <td width="50%"><b>전체 글:${count}</b></td>
    <td align="right" bgcolor="${value_c}">
    <a href="writeForm.do">글쓰기</a>||<a href="../index.jsp">메인화면</a>
    </td>
</tr>    
</table>
<c:if test="${count == 0}">
<table width="700" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
      게시판에 저장된 글이 없습니다.
    </td>
  </tr>
</table>
</c:if>

<c:if test="${count > 0}">
<table border="1" width="700" cellpadding="0" cellspacing="0" align="center"> 
    <tr height="30" bgcolor="${value_c}"> 
      <td align="center"  width="50"  >번 호</td> 
      <td align="center"  width="250" >제   목</td> 
      <td align="center"  width="100" >작성자</td>
      <td align="center"  width="150" >작성일</td> 
      <td align="center"  width="50" >조 회</td> 
      <td align="center"  width="100" >IP</td>    
    </tr>

   <c:forEach var="article" items="${articleList}">
   <tr height="30">
    <td align="center"  width="50" >
	  <c:out value="${number}"/>
	  <c:set var="number" value="${number - 1}"/>
	</td>
    <td  width="250" >
	  <c:if test="${article.re_level > 0}">
	  	<img src="/drBank/images/level.gif" width="${10 * article.re_level}" height="16">
	    <img src="/drBank/images/re.gif">
	  </c:if>
	  <c:if test="${article.re_level == 0}">
	    <img src="/drBank/images/level.gif" width="${10 * article.re_level}" height="16">
	  </c:if>
           
      <a href="/drBank/board/content.do?num=${article.num}&pageNum=${currentPage}">
          ${article.subject}</a> 
          <c:if test="${article.readcount >= 20}">
            <img src="/board/images/hot.gif" border="0"  height="16">
		  </c:if>
	</td>
    <td align="center"  width="100">${article.id}
	</td>
    <td align="center"  width="150">${article.reg_date}
	</td>
    <td align="center"  width="50">${article.readcount}</td>
    <td align="center" width="100" >${article.ip}</td>
  </tr>
  
  </c:forEach>
</table>
</c:if>

<c:if test="${count > 0}">
   <c:set var="pageCount" value="${(count - 1) / pageSize + 1}"/>
   <c:set var="pageBlock" value="${10}"/>
   <fmt:parseNumber var="rs" value="${(currentPage - 1) / pageBlock}" integerOnly="true" />
   <c:set var="startPage" value="${rs*pageBlock+1}"/>
   <c:set var="endPage" value="${startPage + pageBlock-1}"/>
   <c:if test="${endPage > pageCount}">
        <c:set var="endPage" value="${pageCount}"/>
   </c:if> 
          
   <c:if test="${startPage > pageBlock}">
        <a href="/drBank/board/list.do?pageNum=${startPage - pageBlock }&keyField=${keyField}&keyWord=${keyWord}">[이전]</a>
   </c:if>

   <c:forEach var="i" begin="${startPage}" end="${endPage}">
       <c:if test="${i == currentPage}">
          [${i}]
       </c:if>
       <c:if test="${i != currentPage}">
           <a href="/drBank/board/list.do?pageNum=${i}&keyField=${keyField}&keyWord=${keyWord}">[${i}]</a>
       </c:if>
   </c:forEach>

   <c:if test="${endPage < pageCount}">
        <a href="/drBank/board/list.do?pageNum=${startPage + pageBlock}&keyField=${keyField}&keyWord=${keyWord}">[다음]</a>
   </c:if>
</c:if>
	
</center>
</body>
</html>